<extend name="template/base_index" />

<block name="area_header">
    <link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
    <style>.pink{color:pink;}</style>
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/cosmo-skin.css" />
    <script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}
            <!-- 过滤\查询按钮 -->
            <div class="filter-controls">
                {:W('OrgArea/area')}
                <!-- 日期查询 -->
                <form action="{:U('Admin/Orders/index')}" method="post" class="searchForm form-inline">
                    <div class="form-group row   col-lg-12 col-md-12">
                        <div class="input-group" style="width:480px;">
                            <div class="input-group-addon input-sm">用户名</div>
                            <input type="text" name="nickname" placeholder="请输入用户名！" class="form-control input-sm" value="{$nickname}" />
                        </div>
                        <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
                    </div>
                    <div class="form-group row   col-lg-12 col-md-12">
                        <div class="input-group" style="width:480px;">
                            <div class="input-group-addon input-sm">订单编号</div>
                            <input type="text" name="order_code" placeholder="请输入订单编号！" class="form-control input-sm" value="{$order_code}" />
                        </div>
                        <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
                    </div>
                    <div class="form-group row  col-lg-12 col-md-12">
                        <div class="input-group " style="  width: 780px;">
                            <div class="input-group-addon input-sm">评价状态</div>
                            <div class="form-control input-sm">
                                <label class="radio-inline">
                                    <input type="radio" name="commentstatus" class="commentstatus" <eq name="commentStatus" value="">checked="checked"</eq> value="">不限
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="commentstatus" class="commentstatus" <eq name="commentStatus" value="0">checked="checked"</eq> value="0">待评价
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="commentstatus" class="commentstatus" <eq name="commentStatus" value="1">checked="checked"</eq> value="1">已评价
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group row  col-lg-12 col-md-12">
                        <div class="input-group " style="  width: 780px;">
                            <div class="input-group-addon input-sm">支付状态</div>
                            <div class="form-control input-sm">
                                <label class="radio-inline">
                                    <input type="radio" name="paystatus" class="paystatus" <eq name="payStatus" value="">checked="checked"</eq> value="">不限
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="paystatus" class="paystatus" <eq name="payStatus" value="0">checked="checked"</eq> value="0">待支付
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="paystatus" class="paystatus" <eq name="payStatus" value="1">checked="checked"</eq> value="1">已支付
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="paystatus" class="paystatus" <eq name="payStatus" value="2">checked="checked"</eq> value="2">已退款
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group row col-lg-12 col-md-12">
                        <div class="input-group" style="  width: 860px;">
                            <div class="input-group-addon input-sm">订单状态</div>
                            <div class="form-control input-sm">
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="">checked="checked"</eq> value="">不限
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="2">checked="checked"</eq> value="2">待确认
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="3">checked="checked"</eq> value="3">待发货
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="4">checked="checked"</eq> value="4">已发货
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="5">checked="checked"</eq> value="5">已收货
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="6">checked="checked"</eq> value="6">已退货
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="7">checked="checked"</eq> value="7">已完成
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="8">checked="checked"</eq> value="8">已取消
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="orderstatus" class="orderstatus" <eq name="orderStatus" value="12">checked="checked"</eq> value="12">被退回
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group col-lg-12 col-md-12">
                        <div class="input-group">
                            <div class="input-group-addon input-sm">
                                时间
                                <i class="fa fa-calendar"></i>
                            </div>
                            <input type="text" name="startdatetime" id="startdatetime" class="form-control input-short input-sm" value="{$startdatetime}" />
                            <div class="input-group-addon input-sm">
                                <i class="fa fa-long-arrow-right"></i>
                            </div>
                            <input type="text" name="enddatetime" id="enddatetime" class="form-control input-short input-sm" value="{$enddatetime}" />
                        </div>
                        <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}</button>
                    </div>
                </form>
            </div>
            <!-- 操作按钮 -->
            <div class="btn-controls">
            </div>
            <table class="table table-striped table table-hover  table-condensed">
                <thead>
                <tr>
                    <th>
                        <input type="checkbox" class="selectall" onclick="myUtils.selectall(this,'.selectitem');" />
                    </th>
                    <th>
                        订单编号
                    </th>
                    <th>
                        下单用户
                    </th>
                    <th>
                        收货人
                    </th>
                    <th>
                        联系号码
                    </th>
                    <th>
                        总价格(元)
                    </th>
                    <th>
                        邮费(元)
                    </th>
                    <th>
                        已付余额(元)
                    </th>
                    <th>
                        邮寄地址
                    </th>
                    <th>
                        订单状态
                    </th>
                    <th>
                        下单时间
                    </th>
                    <!--<th>-->
                    <!--操作-->
                    <!--</th>-->
                </tr>
                </thead>
                <tbody>
                <empty name="list">
                    <tr>
                        <td colspan="10" class="text-center">{:L('NO_DATA')}</td>
                    </tr>
                    <else/>
                    <volist name="list" id="vo">
                        <tr>
                            <td>
                                <input type="checkbox" value="{$vo.id}" name="ids[]" class="selectitem" />
                            </td>
                            <td>
                                <a href="{:U('Admin/Orders/view',array('id'=>$vo['id']))}">{$vo.order_code}</a>
                            </td>
                            <td>
                                <a href="{:U('Admin/CustomerInfo/index',array('id'=>$vo['uid']))}">{$vo.username}</a>
                            </td>
                            <td>
                                {$vo.contactname}
                            </td>
                            <td>
                                {$vo.mobile}
                            </td>
                            <td>
                                {$vo['price']}
                            </td>
                            <td <gt name="vo.post_price" value="0" >class="pink"</gt>>
                            {$vo['post_price']}
                            </td>
                            <td <gt name="vo.pay_balance" value="0" >class="pink"</gt>>{$vo.pay_balance}</td>
                            <td>
                                {$vo.country},{$vo.province},{$vo.city},{$vo.area},{$vo.detailinfo}
                            </td>
                            <td>
                                [{$vo.pay_status|getPayStatus}]|[{$vo.order_status|getOrderStatus}]|[{$vo.comment_status|getCommentStatus}]
                            </td>
                            <td>
                                {$vo.createtime|date='Y-m-d H:i:s',###}
                            </td>
                            <td>
                                <!--<a href="{:U('Admin/Wxpay/orderQuery',array('orderid'=>$vo['orderid']))}" class="btn btn-default btn-sm "><i class="fa fa-credit-card"></i>查询订单支付记录</a>-->
                                <!--<a href="{:U('Admin/Orders/uploadZjport',array('order_code'=>$vo['order_code']))}" class="btn btn-default btn-sm ">订单上报</a>-->
                            </td>
                        </tr>

                    </volist>
                </empty>
                </tbody>
            </table>
            <div>{$show}</div>


            <script type="text/javascript">
                $(function() {
                    $(".orderstatus").click(function(){
                        $(".searchForm").submit();
                    });
                    $(".commentstatus").click(function(){
                        $(".searchForm").submit();
                    });
                    $(".paystatus").click(function(){
                        $(".searchForm").submit();
                    })

                    $('#startdatetime').datetimepicker({
                        lang: 'ch',
                        format:'Y-m-d H:i:s',
                        timepickerScrollbar:false,
                        scrollMonth:false,
                        scrollTime:false,
                        scrollInput:false
                        // format:'Y-m-d',
                        // timepicker:false,
                    });
                    $('#enddatetime').datetimepicker({
                        lang: 'ch',
                        format:'Y-m-d H:i:s',
                        timepickerScrollbar:false,
                        scrollMonth:false,
                        scrollTime:false,
                        scrollInput:false
                    });
                });
            </script>
        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
</block>

<block name="area_footer">

    <script src="__CDN__/select2/4.0.0/js/select2.min.js"></script>
    <script src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#user_select2").select2({
                placeholder: "输入用户id或昵称查询"	,
                language: "zh-CN",
                ajax: {
                    url: "{:U('Admin/Member/select')}",
                    dataType: 'json',
                    delay: 250,
                    data: function (params) {
                        var queryParameters = {
                            q: params.term
                        }
                        return queryParameters;

                    },
                    processResults: function (data, page) {
                        if(!data.info){
                            data.info = new Array();
                            data.info['nodata']="无相关数据";
                        }
                        // parse the results into the format expected by Select2.
                        // since we are using custom formatting functions we do not need to
                        // alter the remote JSON data
                        return {
                            results: data.info
                        };
                    },
                    cache: true
                },
                minimumInputLength: 0,
                templateSelection: function (repo) {
                    return repo.nickname || repo.text;
                },
                templateResult: function (repo) {

                    if (repo.loading) return repo.text;
                    if(repo.nodata) return repo.nodata;
//    				var markup = '<div>'+repo.nickname+'</div>';
                    var markup = '<div><img src="'+repo.head+'" style="width:30px;height:30px;"/>[id:'+repo.id+'] '+repo.nickname+'</div>';
                    return $(markup);
                },
            });
        });
    </script>

</block>